<template>
	<div class="adminman">
		<div class="adminmanbody">
			<h3>欢迎来到简陋的(暂时)管理员后台系统<router-link to="/" class="quitadmin">退出后台</router-link>
			</h3>

			<div style="margin-top: 40px; margin-left: 30px;">
				<el-button type="primary" @click="check()">查看图书</el-button>
				<el-button type="primary" @click="add()">添加图书</el-button>
				<el-button type="primary" @click="checkuser()">查看用户</el-button>
				<el-button type="primary" @click="checkorder()">查看订单</el-button>
				<div v-show="checkbook" class="checkbook" style="margin-left: 20px;margin-top: 35px;">
					<el-input type="text" placeholder="请输入书本编号" v-model="select_id"
						style="width: 200px;margin-left: 0px;" />
					<el-input type="text" placeholder="请输入图书名称" v-model="select_name"
						style="width: 200px;margin-left: 50px;" />
					<el-input type="text" placeholder="请输入图书类型" v-model="select_type"
						style="width: 200px;margin-left: 50px;" />
					<el-button type="primary" @click="sel()" style="margin-left: 60px;">搜索</el-button>
					<el-button type="success" @click="exl()" style="margin-left: 20px;">导出</el-button>
					<!--分页工具条-->
					<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
						:current-page.sync="currentPage4" :page-sizes="[5, 10]" :page-size="pageSize"
						layout="total, sizes, prev, pager, next, jumper" :total="totalCount">
					</el-pagination>
					<el-table :data="bookList" style="width: 100%" @selection-change="handleSelectionChange"
						:row-class-name="tableRowClassName">
						<el-table-column label="图片" width="" align="center" header-align="center">
							<template v-slot="scope">
								<el-image style="width: 100px; height: 100px"
									:src="require('@/assets/img/'+scope.row.book_pic+'.jpg')" />
							</template>
						</el-table-column>
						<el-table-column prop="bid" label="书本编号" width="" align="center" header-align="center">
						</el-table-column>
						<el-table-column prop="book_name" label="书本名称" width="150px" align="center"
							header-align="center">
						</el-table-column>
						<el-table-column prop="book_type" label="书本类型" width="100px" align="center"
							header-align="center">
						</el-table-column>
						<!-- <el-table-column prop="book_intro" label="书本简介">
						</el-table-column> -->
						<el-table-column prop="book_number" label="库存" width="" align="center" header-align="center">
						</el-table-column>
						<el-table-column prop="book_sale" label="销售量" width="" align="center" header-align="center">
						</el-table-column>
						<el-table-column prop="book_balance" label="价格" width="" align="center" header-align="center">
						</el-table-column>
						<el-table-column prop="book_membalance" label="会员价" width="" align="center"
							header-align="center">
						</el-table-column>
						<el-table-column align="center" label="操作" width="160px" v-slot="scope" header-align="center">
							<el-row>
								<el-button type="primary" @click="updatemsg(scope.$index,scope.row)">修改</el-button>
								<el-button type="danger" @click="removemsg(scope.$index,scope.row)">删除</el-button>
							</el-row>
						</el-table-column>
					</el-table>
				</div>
				<div v-show="addbook" class="addbook">
					<p>图书名:
						<el-input type="text" placeholder="请输入图书名" v-model="book_name" style="width: 200px;" />
					</p>
					<p>类&ensp;&ensp;型:
						<el-input type="hidden" placeholder="请输入类型" v-model="book_type" style="width: 200px;" />
						<select name='' id='' v-model="type1" style="width: 50px;height: 30px;">
							<option value="玄幻">玄幻</option>
							<option value="惊悚">惊悚</option>
							<option value="生活">生活</option>
							<option value="动漫">动漫</option>
							<option value="艺术">艺术</option>
							<option value="青春">青春</option>
							<option value="言情">言情</option>
							<option value="校园">校园</option>
							<option value="体育">体育</option>
							<option value="保健">保健</option>
							<option value="历史">历史</option>
						</select>
						<select name='' id='' v-model="type2" style="width: 50px;height: 30px;margin-left: 20px;">
							<option value="">无</option>
							<option value="玄幻">玄幻</option>
							<option value="惊悚">惊悚</option>
							<option value="生活">生活</option>
							<option value="动漫">动漫</option>
							<option value="艺术">艺术</option>
							<option value="青春">青春</option>
							<option value="言情">言情</option>
							<option value="校园">校园</option>
							<option value="体育">体育</option>
							<option value="保健">保健</option>
							<option value="历史">历史</option>
						</select>
						<select name='' id='' v-model="type3" style="width: 50px;height: 30px;margin-left: 20px;">
							<option value="">无</option>
							<option value="玄幻">玄幻</option>
							<option value="惊悚">惊悚</option>
							<option value="生活">生活</option>
							<option value="动漫">动漫</option>
							<option value="艺术">艺术</option>
							<option value="青春">青春</option>
							<option value="言情">言情</option>
							<option value="校园">校园</option>
							<option value="体育">体育</option>
							<option value="保健">保健</option>
							<option value="历史">历史</option>
						</select>
					</p>
					<p>简&ensp;&ensp;介:
						<el-input type="text" placeholder="请输入图书简介" v-model="book_intro" style="width: 700px;" />
					</p>
					<p>库&ensp;&ensp;存:
						<el-input type="text" placeholder="请输入库存" v-model="book_number" style="width: 200px;" />
					</p>
					<p>价&ensp;&ensp;格:
						<el-input type="text" placeholder="请输入图书价格" v-model="book_balance" style="width: 200px;" />
					</p>
					<p>折&ensp;&ensp;扣:
						<el-input type="text" placeholder="请输入折扣" v-model="book_discount" style="width: 200px;" />
					</p>
					<p>图&ensp;&ensp;片:
						<el-upload action="https://jsonplaceholder.typicode.com/posts/" :file-list="fileList"
							@on-change="handleChange" :http-request="getFile">
							<el-button size="small" type="primary">上传</el-button>
						</el-upload>
					</p>
					<el-button type="button" class="addbookbtn" @click="addsql()" style="margin-top: 10px;">提交数据
					</el-button>

				</div>
				<div style="margin-top: 20px;"></div>
				<div v-show="updatebook" class="updatebook">
					<p>
						<!-- 图书编号: -->
						<el-input type="text" placeholder="请输入编号" v-model="bid" style="width: 200px;"
							:disabled="true" />
					</p>
					<p>
						<!-- 图&ensp;书&ensp;名: -->
						<el-input type="text" placeholder="请输入图书名" v-model="upbook_name" style="width: 200px;" />
					</p>
					<p>
						<select name='' id='' v-model="up_type1" style="width: 50px;height: 30px;">
							<option value="玄幻">玄幻</option>
							<option value="惊悚">惊悚</option>
							<option value="生活">生活</option>
							<option value="动漫">动漫</option>
							<option value="艺术">艺术</option>
							<option value="青春">青春</option>
							<option value="言情">言情</option>
							<option value="校园">校园</option>
							<option value="体育">体育</option>
							<option value="保健">保健</option>
							<option value="历史">历史</option>
						</select>
						<select name='' id='' v-model="up_type2" style="width: 50px;height: 30px;margin-left: 20px;">
							<option value="">无</option>
							<option value="玄幻">玄幻</option>
							<option value="惊悚">惊悚</option>
							<option value="生活">生活</option>
							<option value="动漫">动漫</option>
							<option value="艺术">艺术</option>
							<option value="青春">青春</option>
							<option value="言情">言情</option>
							<option value="校园">校园</option>
							<option value="体育">体育</option>
							<option value="保健">保健</option>
							<option value="历史">历史</option>
						</select>
						<select name='' id='' v-model="up_type3" style="width: 50px;height: 30px;margin-left: 20px;">
							<option value="">无</option>
							<option value="玄幻">玄幻</option>
							<option value="惊悚">惊悚</option>
							<option value="生活">生活</option>
							<option value="动漫">动漫</option>
							<option value="艺术">艺术</option>
							<option value="青春">青春</option>
							<option value="言情">言情</option>
							<option value="校园">校园</option>
							<option value="体育">体育</option>
							<option value="保健">保健</option>
							<option value="历史">历史</option>
						</select>
					</p>
					<p>
						<!-- 简&ensp;&ensp;&ensp;&ensp;介: -->
						<el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入内容"
							v-model="upbook_intro" style="width: 200px;">
						</el-input>

					</p>
					<p>
						<!-- 库&ensp;&ensp;&ensp;&ensp;存: -->
						<el-input type="text" placeholder="请输入库存" v-model="upbook_number" style="width: 200px;" />
					</p>
					<p>
						<!-- 价&ensp;&ensp;&ensp;&ensp;格: -->
						<el-input type="text" placeholder="请输入图书价格" v-model="upbook_balance" style="width: 200px;" />
					</p>
					<p>
						<!-- 价&ensp;&ensp;&ensp;&ensp;格: -->
						<el-input type="text" placeholder="请输入折扣" v-model="upbook_discount" style="width: 200px;" />
					</p>
					<p>
						<!-- 图&ensp;&ensp;&ensp;&ensp;片: -->
						<el-input type="file" id="imgfile" ref="myFile" />
					</p>
					<el-button type="button" class="addbookbtn" @click="updatesql() " style="margin-top: 10px;">提交数据
					</el-button>
				</div>
				<div style="margin-top: 40px;"></div>
				<div v-show="checkusermsg" class="checkbook" style="margin-left: 20px;">
					<el-input type="text" placeholder="请输入用户ID" v-model="select_user_uid"
						style="width: 200px;margin-left: 50px;" />
					<el-input type="text" placeholder="请输入用户帐号" v-model="select_user_username"
						style="width: 200px;margin-left: 50px;" />
					<el-input type="text" placeholder="请输入用户名" v-model="select_user_name"
						style="width: 200px;margin-left: 50px;" />
					<el-button type="primary" @click="sel()" style="margin-left: 60px;">搜索</el-button>
					<!--分页工具条-->
					<el-pagination @size-change="handleSizeChange1" @current-change="handleCurrentChange1"
						:current-page.sync="currentPage4" :page-sizes="[1,5,10]" :page-size="pageSize1"
						layout="total, sizes, prev, pager, next, jumper" :total="totalCount1">
					</el-pagination>
					<el-table :data="userList" style="width: 100%" @selection-change="handleSelectionChange"
						:row-class-name="tableRowClassName">
						<el-table-column prop="uid" label="用户ID" width="" align="center" header-align="center">
						</el-table-column>
						<el-table-column prop="username" label="帐号" align="center" header-align="center">
						</el-table-column>
						<el-table-column prop="password" label="密码" align="center" header-align="center">
						</el-table-column>
						<el-table-column prop="userMessages.name" label="用户名" width="" align="center"
							header-align="center">
						</el-table-column>
						<!-- <el-table-column prop="book_intro" label="书本简介">
						</el-table-column> -->
						<el-table-column prop="userMessages.point" label="积分" width="" align="center"
							header-align="center">
						</el-table-column>
						<el-table-column prop="userMessages.balance" label="余额" width="" align="center"
							header-align="center">
						</el-table-column>
						<el-table-column prop="userMessages.gender" label="性别" width="" align="center"
							header-align="center">
						</el-table-column>
						<el-table-column prop="userMessages.age" label="年龄" width="" align="center"
							header-align="center">
						</el-table-column>
						<el-table-column align="center" label="操作" width="160px" v-slot="scope" header-align="center">
							<el-row>
								<el-button type="primary" @click="updateusermsg(scope.$index,scope.row)"
									style="margin-left: 40px;">修改</el-button>
							</el-row>
						</el-table-column>
					</el-table>
				</div>
				<div v-show="updateuser" class="updateuser">
					<p>
						<el-input type="text" placeholder="用户ID" v-model="uid" style="width: 200px;" :disabled="true" />
					</p>
					<p>
						<el-input type="text" placeholder="帐号" v-model="username" style="width: 200px;"
							:disabled="true" />
					</p>
					<p>
						<el-input type="text" placeholder="请输入密码" v-model="upuser_password" style="width: 200px;">
						</el-input>
					</p>
					<p>
						<el-input type="text" placeholder="请输入用户名" v-model="upuser_name" style="width: 200px;" />
					</p>
					<p>
						<el-input type="textarea" placeholder="请输入家庭住址" v-model="upuser_address"
							style="width: 200px;" />

					</p>
					<p>
						<el-input type="text" placeholder="请输入电话" v-model="upuser_phone" style="width: 200px;" />
					</p>
					<p>
						<el-input type="text" placeholder="邮箱" v-model="upuser_mail" style="width: 200px;" />
					</p>

					<el-button type="button" class="addbookbtn" @click="updateusertoaql() " style="margin-top: 10px;">
						提交数据
					</el-button>
				</div>
				<div v-show="checkordermsg" class="checkbook" style="margin-left: 20px;">
					<el-input type="text" placeholder="请输入书本编号" v-model="select_id"
						style="width: 200px;margin-left: 50px;" />
					<el-input type="text" placeholder="请输入图书名称" v-model="select_name"
						style="width: 200px;margin-left: 50px;" />
					<el-input type="text" placeholder="请输入图书类型" v-model="select_type"
						style="width: 200px;margin-left: 50px;" />
					<el-button type="primary" @click="sel()" style="margin-left: 60px;">搜索</el-button>
					<!--分页工具条-->
					<el-pagination @size-change="handleSizeChange2" @current-change="handleCurrentChange2"
						:current-page.sync="currentPage4" :page-sizes="[5, 10]" :page-size="pageSize2"
						layout="total, sizes, prev, pager, next, jumper" :total="totalCount2">
					</el-pagination>
					<el-table :data="orderList" style="width: 100%" :row-class-name="tableRowClassName"
						@selection-change="handleSelectionChange">
						<el-table-column prop="buy_id" label="订单编号" align="center" header-align="center">
						</el-table-column>
						<el-table-column label="图片" width="" align="center" header-align="center">
							<template v-slot="scope">
								<el-image style="width: 100px; height: 100px"
									:src="require('@/assets/img/'+scope.row.book_pic+'.jpg')" />
							</template>
						</el-table-column>
						<el-table-column prop="bid" label="书本编号" align="center" header-align="center">
						</el-table-column>
						<el-table-column prop="book_name" label="书本名称" width="100" align="center" header-align="center">
						</el-table-column>
						<el-table-column prop="order_address" width="180" label="收货地址" align="center"
							header-align="center">
						</el-table-column>
						<el-table-column prop="order_phone" width="150" label="电话" align="center" header-align="center">
						</el-table-column>
						<el-table-column prop="book_membalance" label="购买价格" align="center" header-align="center">
						</el-table-column>
						<el-table-column prop="book_status" label="订单状态" align="center" header-align="center">
						</el-table-column>
						<el-table-column align="center" label="操作" width="" v-slot="scope" header-align="center">
							<el-row>
								<el-button type="danger" @click="removeorder(scope.$index,scope.row)">删除</el-button>
							</el-row>
						</el-table-column>
					</el-table>
				</div>
				<h2>系统正在继续开发,请等待后续功能....</h2>
			</div>
		</div>
	</div>
</template>

<script>
	import axios from "axios";
	export default {
		name: "Adminmanage",
		data() {
			return {
				type1: "玄幻",
				type2: '',
				type3: '',
				fileList: [],
				visible: false,
				loading: null,
				//hideUploadEdit: false, //是否隐藏上传按钮
				bookList: [],
				userList: [],
				orderList: [],
				checkusermsg: false,
				checkordermsg: false,
				addbook: false,
				updatebook: false,
				checkbook: false,
				updateuser: false,
				book_name: '',
				book_type: '',
				book_intro: '',
				book_number: '',
				book_balance: '',
				book_discount: '',
				book_membalance: '',
				// 每页显示的条数
				pageSize: 10,
				pageSize1: 5,
				pageSize2: 10,
				// 总记录数
				totalCount: 100,
				totalCount1: 100,
				totalCount2: 100,
				// 当前页码
				currentPage: 1,
				currentPage1: 1,
				currentPage2: 1,
				currentRowIndex: '',
				dataonLineListSelections: [],
				bid: '',
				upbook_name: '',
				upbook_type: '',
				up_type1: '玄幻',
				up_type2: '',
				up_type3: '',
				upbook_intro: '',
				upbook_number: 0,
				upbook_balance: 0,
				upbook_discount: 0,
				select_name: '',
				select_id: '',
				select_type: '',
				selectbook: {
					bid: '',
					book_name: '',
					book_type: ''
				},
				uid: '',
				username: '',
				upuser_password: '',
				upuser_name: '',
				upuser_address: '',
				upuser_phone: '',
				upuser_mail: '',
				select_user_uid: '',
				select_user_username: '',
				select_user_name: '',
				selectusermsg: {
					uid: '',
					username: '',
					user_name: '',
				},
				book: {
					bid: '',
					book_name: '',
					book_type: '',
					book_intro: "",
					book_number: "",
					book_balance: "",
					book_discount: '',
					book_membalance: '',
				},
			}
		},
		created() {
			//this.findAll();
			this.findByPages();
			this.findUser();
			this.findOrder();
		},
		methods: {
			sel: function() {
				this.selectbook.bid = this.select_id;
				this.selectbook.book_name = this.select_name;
				this.selectbook.book_type = this.select_type;
				this.findByPages()
			},
			findByPages() {
				axios({
					method: "post",
					url: "http://localhost:8080/book/selectbypc?currentPage=" + this
						.currentPage + "&pageSize=" + this.pageSize,
					data: this.selectbook
				}).then(res => {
					//设置表格数据
					this.bookList = res.data.rows; // {rows:[],totalCount:100}
					//设置总记录数
					this.totalCount = res.data.totalCount;
				})
			},
			findUser() {
				axios({
					method: "post",
					url: "http://localhost:8080/user/selectbypageUser?currentPage=" + this
						.currentPage1 + "&pageSize=" + this.pageSize1
				}).then(res => {
					//设置表格数据
					this.userList = res.data.rows; // {rows:[],totalCount:100}
					//设置总记录数
					this.totalCount1 = res.data.totalCount;
				})
			},
			findOrder() {
				axios({
					method: "post",
					url: "http://localhost:8080/order/selectbypageOrder?currentPage=" + this
						.currentPage2 + "&pageSize=" + this.pageSize2,
				}).then(res => {
					//设置表格数据
					this.orderList = res.data.rows; // {rows:[],totalCount:100}
					//设置总记录数
					this.totalCount2 = res.data.totalCount;
				})
			},
			//分页
			handleSizeChange(val) {
				//console.log(`每页 ${val} 条`);
				// 重新设置每页显示的条数
				this.pageSize = val;
				this.findByPages();
			},
			handleCurrentChange(val) {
				//console.log(`当前页: ${val}`);
				// 重新设置当前页码
				this.currentPage = val;
				this.findByPages();
			},
			//分页
			handleSizeChange1(val) {
				//console.log(`每页 ${val} 条`);
				// 重新设置每页显示的条数
				this.pageSize1 = val;
				this.findUser();
			},
			handleCurrentChange1(val) {
				//console.log(`当前页: ${val}`);
				// 重新设置当前页码
				this.currentPage1 = val;
				this.findUser();
			},
			handleSizeChange2(val) {
				//console.log(`每页 ${val} 条`);
				// 重新设置每页显示的条数
				this.pageSize2 = val;
				this.findOrder();
			},
			handleCurrentChange2(val) {
				//console.log(`当前页: ${val}`);
				// 重新设置当前页码
				this.currentPage2 = val;
				this.findOrder();
			},
			//通过onchanne触发方法获得文件列表
			handleChange(file, fileList) {
				this.fileList = fileList;
				alert(this.fileList)
			},
			check() {
				this.checkbook = !this.checkbook;
				this.addbook = false
				this.updatebook = false
				this.checkordermsg = false
				this.checkusermsg = false
			},
			checkuser() {
				this.checkusermsg = !this.checkusermsg;
				this.addbook = false
				this.updatebook = false
				this.checkordermsg = false
				this.checkbook = false
				this.findUser()
			},
			checkorder() {
				this.checkordermsg = !this.checkordermsg;
				this.addbook = false
				this.updatebook = false
				this.checkusermsg = false
				this.checkbook = false
			},
			add() {
				this.addbook = !this.addbook
				this.updatebook = false
				this.checkbook = false
				this.checkordermsg = false
				this.checkusermsg = false
			},
			addsql() { //添加到数据库
				if (((this.type1 == this.type2) || (this.type1 == this.type3) || (this.type2 == this
						.type3)) && this.type2 != '') {
					alert("书本的类型不能一样")
				} else {
					this.book_type = this.type1
					if (this.type2 != '') {
						if (this.type1 != this.type2) {
							this.book_type = this.book_type + "," + this.type2
						}
					}
					if (this.type3 != '') {
						if (this.type1 != this.type3) {
							this.book_type = this.book_type + "," + this.type3
						}
					}
					if (this.book_name == '' || this.book_type == '' || this.book_intro == '' || this
						.book_number < 0 || this.book_balance < 0 || this.book_discount < 0) {
						alert("请正确填写所有数据!!!")
					} else {
						const fd = new FormData()
						fd.append('filename', this.file)
						const config = {
							headers: {
								'Content-Type': 'multipart/form-data'
							}
						}
						axios.post('http://localhost:8080/book/insertbook?' + 'book_name=' + this.book_name +
								'&book_type=' +
								this.book_type + '&book_intro=' + this.book_intro + '&book_number=' + this
								.book_number +
								'&book_balance=' + this.book_balance + '&book_discount=' + this.book_discount, fd,
								config
							)
							.then(res => {
								alert(res.data)
								this.findByPages();
							})
					}
				}
			},
			updatesql(index) { //添加到数据库	
				if (((this.up_type1 == this.up_type2) || (this.up_type1 == this.up_type3) || (this.up_type2 ==
						this
						.up_type3)) && this.up_type2 != '') {
					alert("书本的类型不能一样")
				} else {
					this.upbook_type = this.up_type1
					if (this.up_type2 != '') {
						if (this.up_type1 != this.up_type2) {
							this.upbook_type = this.upbook_type + "," + this.up_type2
						}
					}
					if (this.up_type3 != '') {
						if (this.up_type1 != this.up_type3) {
							this.upbook_type = this.upbook_type + "," + this.up_type3
						}
					}
					if (this.upbook_name == '' || this.upbook_type == '' || this.upbook_intro == '' || this
						.upbook_number < 0 || this.upbook_balance < 0) {
						alert("请正确填写所有数据!!!")
					} else {
						axios.post('http://localhost:8080/book/updatebook',
								'bid=' + this.bid + '&book_name=' + this.upbook_name + '&book_type=' + this
								.upbook_type +
								'&book_intro=' + this.upbook_intro +
								'&book_number=' + this.upbook_number + '&book_balance=' + this.upbook_balance +
								'&book_discount=' + this.upbook_discount)
							.then(res => {
								alert(res.data)
								this.updatebook = !this.updatebook;
								this.findByPages();
							}).catch(function(error) {
						console.log(error);
					});
					}
				}
			},
			//将表格数据导出为excel
			exl() {
			  this.$confirm('是否导出Excel?', '提示', {
			    confirmButtonText: '确定',
			    cancelButtonText: '取消',
			    type: 'warning',
			    center: true
			  }).then(() => {
			    axios({
			      method: 'post',
			      url: 'http://localhost:8080/excel/exportLesson',
			      responseType: 'blob'
			    }).then((res) => {
			      console.log(res)
			      const link = document.createElement('a')
			      let blob = new Blob([res.data], {
			        type: 'application/vnd.ms-excel'
			      });
			      link.style.display = 'none'
			      link.href = URL.createObjectURL(blob);
			      console.log("href:" + link.href)
			      let num = ''
			      for (let i = 0; i < 10; i++) {
			        num += Math.ceil(Math.random() * 10)
			      }
			      link.setAttribute('download', num + '.xls')
			      document.body.appendChild(link)
			      link.click()
			      document.body.removeChild(link)
			      this.$message({
			        type: 'success',
			        message: '导出成功!!!'
			      });
			    })
			  }).catch(() => {
			    //用户点击取消按钮
			    this.$message({
			      type: 'info',
			      message: '已取消导出操作'
			    });
			  });
			},
			tableRowClassName({
				row,
				rowIndex
			}) {
				row.row_index = rowIndex;
			},
			//通过onchanne触发方法获得文件列表
			handleChange(file, fileList) {
				this.fileList = fileList;
				alert(this.fileList);
			},
			updatemsg(index, row) {
				this.updatebook = !this.updatebook;
				this.currentRowIndex = row.row_index;
				this.bid = this.bookList[this.currentRowIndex].bid;
				this.upbook_name = this.bookList[this.currentRowIndex].book_name;
				this.upbook_intro = this.bookList[this.currentRowIndex].book_intro;
				this.upbook_type = this.bookList[this.currentRowIndex].book_type;
				if (this.upbook_type.split(",").length == 1) {
					this.up_type1 = this.upbook_type.split(",")[0]
					this.up_type2 = ''
					this.up_type3 = ''
				} else if (this.upbook_type.split(",").length == 2) {
					this.up_type1 = this.upbook_type.split(",")[0]
					this.up_type2 = this.upbook_type.split(",")[1]
					this.up_type3 = ''
				} else if (this.upbook_type.split(",").length == 3) {
					this.up_type1 = this.upbook_type.split(",")[0]
					this.up_type2 = this.upbook_type.split(",")[1]
					this.up_type3 = this.upbook_type.split(",")[2]
				}
				this.upbook_number = this.bookList[this.currentRowIndex].book_number;
				this.upbook_balance = this.bookList[this.currentRowIndex].book_balance;
				this.upbook_discount = this.bookList[this.currentRowIndex].book_discount;
			},
			updateusermsg(index, row) {
				this.updateuser = !this.updateuser;
				this.currentRowIndex = row.row_index;
				this.uid = this.userList[this.currentRowIndex].uid;
				this.username = this.userList[this.currentRowIndex].username;
				this.upuser_password = this.userList[this.currentRowIndex].password;
				this.upuser_name = this.userList[this.currentRowIndex].userMessages.name;
				this.upuser_address = this.userList[this.currentRowIndex].userMessages.address;
				this.upuser_phone = this.userList[this.currentRowIndex].userMessages.phone;
				this.upuser_mail = this.userList[this.currentRowIndex].userMessages.mail;
			},
			updateusertoaql(index) { //添加到数据库
				if (this.upuser_password == '' || this.upuser_name == '') {
					alert("请正确填写所有数据!!!")
				} else {
					this.$confirm('是否更改该用户的信息?', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					}).then(() => {
						axios.post('http://localhost:8080/user/updateuser',
								'uid=' + this.uid + '&username=' + this.username + '&password=' + this
								.upuser_password +
								'&name=' + this.upuser_name +
								'&address=' + this.upuser_address + '&phone=' + this.upuser_phone +
								'&mail=' + this.upuser_mail)
							.then(res => {
								if (res.data = "success") {
									this.$message({
										type: 'success',
										message: '恭喜您更改成功!',
									});
									this.updateuser = !this.updateuser;
									this.findUser();
								} else {
									this.$message({
										type: 'warning',
										message: res.data
									});
								}
							})
					}).catch(() => {
						this.$message({
							type: 'info',
							message: '已取消删除'
						});
					});

				}
			},
			removemsg(index, row) {
				this.currentRowIndex = row.row_index;
				this.bid = this.bookList[this.currentRowIndex].bid;
				this.$confirm('此操作将永久删除该图书, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					axios.post('http://localhost:8080/book/deletebook', 'bid=' + this.bid)
						.then(res => {
							if (res.data = "success") {
								this.$message({
									type: 'success',
									message: '恭喜您删除成功!',

								});
								this.findByPages();
							} else {
								this.$message({
									type: 'warning',
									message: res.data
								});
							}
						})
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消删除'
					});
				});
			},
			getFile(item) {
				console.log(item.file)
				this.file = item.file
			},
			upload(book_name) {
				const fd = new FormData()
				fd.append('filename', this.file)
				const config = {
					headers: {
						'Content-Type': 'multipart/form-data'
					}
				}
				axios.post('http://localhost:8080/file/uploading?' + 'book_name=' + this.book_name, fd, config)
					.then(response => {
						this.$message.success(response.retCode)
					})
			},
		}
	}
</script>

<style scoped>
	.avatar-uploader .el-upload {
		border: 1px dashed #d9d9d9;
		border-radius: 6px;
		cursor: pointer;
		position: relative;
		overflow: hidden;
	}

	.avatar-uploader .el-upload:hover {
		border-color: #409eff;
	}

	.avatar-uploader-icon {
		font-size: 28px;
		color: #8c939d;
		width: 178px;
		height: 178px;
		line-height: 178px;
		text-align: center;
	}

	.avatar {
		width: 178px;
		height: 178px;
		display: block;
	}

	.addbook p {
		margin-left: 40px;
		margin-top: 10px;
	}

	.addbook p:nth-of-type(3) input {
		width: 700px;
		height: 20px;
	}

	.addbookbtn {
		float: right
	}

	.updatebook {
		position: relative;
		background-color: lightblue;
		width: 300px;
		height: 400px;
		bottom: 950px;
		left: 900px;
		right: 200px;
		z-index: 999;
		border-radius: 10px;
	}

	.updatebook p {
		margin-left: 40px;
		margin-top: 10px;
	}

	.updateuser {
		position: relative;
		background-color: lightblue;
		width: 300px;
		height: 400px;
		bottom: 100px;
		left: 900px;
		right: 200px;
		z-index: 999;
		border-radius: 10px;
	}

	.updateuser p {
		margin-left: 40px;
		margin-top: 10px;
	}
</style>
